<% content_for :toolbar do %>
  <div class="toolbar_buttons">
    <%= render Alchemy::Admin::ToolbarButton.new(
      icon: :plus,
      label: Alchemy.t('New Tag'),
      url: alchemy.new_admin_tag_path,
      title: Alchemy.t('New Tag'),
      hotkey: 'alt+n',
      tooltip_placement: "top-start",
      dialog_options: {
        title: Alchemy.t('New Tag'),
        size: '310x180'
      },
      if_permitted_to: [:create, Alchemy::Tag]
    ) %>
  </div>
  <%= render 'alchemy/admin/partials/search_form' %>
<% end %>

<div id="archive_all" class="resources-table-wrapper">
  <%= render 'alchemy/admin/resources/table_header' %>
  <% if @tags.any? %>

    <%= render Alchemy::Admin::Resource::Table.new(@tags, query: @query, search_filter_params: search_filter_params) do |table| %>
      <% table.icon_column "tag" %>
      <% table.column :name, sortable: true %>
      <% table.column :taggings_types do |tag| %>
        <% tag.taggings.collect(&:taggable).compact.uniq(&:class).each do |taggable| %>
          <span class="label">
            <%= taggable.class.model_name.human %>
          </span>
        <% end %>
      <% end %>
      <% table.column :taggings_count, sortable: true, class_name: "count" %>

      <% table.delete_button tooltip: Alchemy.t(:delete_tag), confirm_message: Alchemy.t(:do_you_really_want_to_delete_this_tag?) %>
      <% table.edit_button tooltip: Alchemy.t(:edit_tag), dialog_size: "360x410" %>
    <% end %>

    <%= render "alchemy/admin/resources/pagination", resources: @tags %>

  <% else %>

  <%= render_message do %>
    <h2><%= Alchemy.t('No Tags found') %></h2>
    <% if search_filter_params[:q].blank? %>
      <p><%= Alchemy.t(:tags_get_created_if_used_the_first_time) %></p>
    <% end %>
  <% end %>

  <% end %>
</div>
